package com.michale.common.domain.permissions;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.michale.common.domain.model.BaseEntity;
import com.michale.common.domain.system.DeptEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @Author Michale
 * @apiNote 角色和菜单关联表实体类
 */
@Data
@TableName("per_user")
@ApiModel(value = "SysUser: 用户信息表", description = "用户信息表")
public class UserEntity extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @ApiModelProperty(value = "角色ID")
    @TableField(exist = false)
    private Long roleId;

    @ApiModelProperty(value = "部门ID")
    private Long deptId;

    @NotBlank(message = "用户账号不能为空")
    @ApiModelProperty(value = "用户账号")
    private String userName;

    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    @ApiModelProperty(value = "用户昵称")
    private String nickName;

    @ApiModelProperty(value = "身份标识(0超级管理员，1 终极管理员 2 初级管理员)")
    private String identity;

    @ApiModelProperty(value = "用户类型（00系统用户）")
    private String userType;

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    @ApiModelProperty(value = "用户邮箱")
    private String email;

    @ApiModelProperty(value = "手机号码")
    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    private String phoneNumber;

    @ApiModelProperty(value = "用户性别（0男 1女 2未知）")
    private String sex;

    @ApiModelProperty(value = "头像地址")
    private String avatar;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "帐号状态（0正常 1停用）")
    private String status;

    @ApiModelProperty(value = "删除标志（0代表存在 2代表删除）")
    private String delFlag;

    @ApiModelProperty(value = "最后登录IP")
    private String loginIp;

    @ApiModelProperty(value = "最后登录时间")
    @TableField(value = "login_date", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date loginDate;

    @ApiModelProperty("角色对象")
    @TableField(exist = false)
    private List<RoleEntity> roleEntityList;

    @ApiModelProperty("部门")
    @TableField(exist = false)
    private DeptEntity deptEntity;

    @ApiModelProperty("角色组")
    @TableField(exist = false)
    private Long[] roleIds;

    @ApiModelProperty("岗位组")
    @TableField(exist = false)
    private Long[] postIds;
}
